/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.edu.upc.dew.sisrest.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import pe.edu.upc.dew.sisrest.model.Noticia;
import pe.edu.upc.dew.sisrest.service.NoticiaManager;

/**
 *
 * @author u201014509
 */
@Controller
public class NoticiaController {

    NoticiaManager noticiaManager;

    @Autowired
    public NoticiaController(NoticiaManager oNoticiaManager){
        this.noticiaManager=oNoticiaManager;
    }

    @RequestMapping("/adm_noticias.htm")
    public void adm_noticias(Model model, @ModelAttribute("Noticia")Noticia noticia ){
        List<Noticia> noticias= noticiaManager.obtenerNoticias();
        model.addAttribute("noticias",noticias);
        model.addAttribute("noticia",noticia);
    }
}
